    import navBar from '../common/Navbar/navbar.vue'
	import { openTable, getTableState, getList,payOrder,clearOrder, getDishList, addDish, delDish, getTableOrderDishList, cancelPay } from '../api/api.js'
	import initWebScoket from '../../utils/webscoket'
	import {mapState, mapMutations, mapActions} from 'vuex'
	export default {
		data() {
			return {
				orderDishPrice: 0,
				openPayType: false,
			}
		},
		computed:{
			tableInfo:function(){
				return this.shopInfo()
			},
			orderListDataes:function() {
				return this.orderListData().dishList
			}
		},
		components: { navBar },
		onLoad() {
			this.init()
		},
		methods: {
			...mapState(['shopInfo', 'orderListData']),
			init(){
				this.computOrderInfo()
			},
			// 订单里和总订单价格计算
			computOrderInfo(){
				let oriData = this.orderListDataes
				this.orderDishPrice = 0;
				oriData.map((n,i) => {
					this.orderDishPrice += n.number * n.price
				})
			},
			// 返回上一级
			goback(){
				uni.navigateBack()
			},
			closeMask(){
				this.openPayType = false
			},
			// 支付下单
			async payOrderHandle(){
				uni.login({success: (res) => {
					if(res.errMsg == 'login:ok'){
						const params = {tableId: this.shopInfo().tableId, jsCode: res.code}
						payOrder(params).then(function(resp){
							const params = JSON.parse(resp.data)
							uni.requestPayment({
								timeStamp: params.timeStamp,
								nonceStr: params.nonceStr,
								package: params.package,
								signType: 'MD5',
								paySign: params.paySign,
								success: (resc) => {
								  console.log('支付成功')
								  uni.navigateTo({url: '/pages/order/success'})
								},
								fail: (err) => {
									// 取消支付告诉后台 解除锁桌
									cancelPay(params).then((rescan) => {
										console.log('取消支付解除锁桌：', rescan)
									}).catch((errcan) => {
										console.log('取消支付解除锁桌失败：', errcan)
									})
									uni.showToast({
										title: '取消支付',
										icon: 'none',
									})
								}
							})
						}).catch(errsc => {
							if (errsc.code == 400){
								this.openPayType = true
								return false
							} else {
								uni.showToast({
									title: errsc.message,
									icon: 'none',
								})
							}
						})
					} else {
						uni.showToast({
							title: '出错了， 请稍后再试！',
							icon: 'none',
						})
					}
				}})
			}
		}
	}